<?php

/**
 * model_message
 */

class Model_message extends YOU {

	public function __construct()
	{
		parent::__construct();
	}
	/** 读取列表 **/
	public function getAll($field = "*")
	{
		$message_lists = $this->db->fetchAll("SELECT {$field} FROM `tbl_message` ");

		return $message_lists;
	}
	
	/** 读取总数 **/
	public function count()
	{
		$row = $this->db->fetchRow("SELECT COUNT(1) AS count FROM `tbl_message`");
		return (int)$row['count'];
	}
	

	/** 读取信息 **/
	public function getInfo($message_id, $field = "*")
	{
		$data = $this->db->fetchRow("SELECT {$field} FROM `tbl_message` WHERE message_id='{$message_id}' ");

		return $data;
	}
	/** 读取评语或是信息 **/
	public function getRow($student_id, $message_type, $semester_id, $field = "*")
	{
		$data = $this->db->fetchRow("SELECT {$field} FROM `tbl_message` WHERE student_id='{$student_id}' AND message_type='{$message_type}' AND semester_id = {$semester_id}");

		return $data;
	}
	/** 读取学生职务 **/
	public function getLeaderRow($student_id, $message_type, $field = "*")
	{
		$data = $this->db->fetchRow("SELECT {$field} FROM `tbl_message` WHERE student_id='{$student_id}' AND message_type='{$message_type}' ");

		return $data;
	}
	
	

}



?>